<template>
  <div class="metric-card" :class="'trend-' + trend">
    <div class="metric-header">
      <h3>{{ title }}</h3>
      <div class="trend-indicator">
        <span v-if="trend === 'up'" class="up">↑</span>
        <span v-if="trend === 'down'" class="down">↓</span>
        <span v-if="trend === 'stable'" class="stable">→</span>
        <span v-if="change" class="change">{{ change }}%</span>
      </div>
    </div>
    <div class="metric-value">{{ value }}</div>
    <div class="metric-footer">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    },
    value: {
      type: [String, Number],
      required: true
    },
    trend: {
      type: String,
      validator: value => ['up', 'down', 'stable'].includes(value),
      default: 'stable'
    },
    change: {
      type: Number,
      default: 0
    }
  }
}
</script>

<style scoped>
.metric-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

h3 {
  margin: 0;
  font-size: 0.9rem;
  color: #7f8c8d;
  font-weight: 500;
}

.trend-indicator {
  font-size: 0.8rem;
  font-weight: bold;
}

.up {
  color: #27ae60;
}

.down {
  color: #e74c3c;
}

.stable {
  color: #3498db;
}

.change {
  margin-left: 4px;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 600;
  color: #2c3e50;
  margin: 8px 0;
}

.metric-footer {
  font-size: 0.8rem;
  color: #95a5a6;
}
</style>